package com.sheepone.distributor.event;

import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.LongAdder;

/**
 * @author Miss.杨
 * @description
 * @since 2024/1/15 - 11:17
 */
public class AbstractEvent {
    private final AtomicBoolean available = new AtomicBoolean(true);
    private final LongAdder retireTimes = new LongAdder();

    public boolean isAvailable(){
        return available.get();
    }

    public boolean doing(){
        return available.compareAndSet(true,false);
    }

    public boolean finished(){
        return available.compareAndSet(false,true);
    }

    public long getRetireTimes(){
        return retireTimes.longValue();
    }

}
